<include file="Common:header" />
<TYimport plugin='datepicker' />
<TYjs file='fix_table_title'/>
<TYjs file='init'/>

<div class="table_content">
    <form action="{:U(MODULE_NAME.'/'.CONTROLLER_NAME.'/'.ACTION_NAME)}" method="post" class="ajax_form">
        <div class="toolbar">
        	<select id="select_orders_status" name="search">
        		<option value="99">全部</option>
        		<option value="1">已付款</option>
        		<option value="0">待付款</option>
        		<option value="-1">退款審核中</option>
                <option value="-2">退款審核成功</option>
                <option value="-3">退款中</option>
        		<option value="-4">退款成功</option>
        	</select>
            <select id="select_orders" name="order_find">
        		<option value="0">订单号</option>
        	</select>
            <!-- 请填订单号 -->
            <input type="text" class="text w150" name="keywords"  title="请填订单号" placeholder="请填订单号"/>
            <!-- 查询 -->
            <button type="submit">查询</button>
        </div>
    </form>

    <form action="{:U(MODULE_NAME.'/'.CONTROLLER_NAME.'/delete_orders')}" method="post" class="ajax_form">
        <table class="orders_table">
            <tr>
                <!-- <th width="40px"><input type="checkbox" class="check_all" title="全选"/></th> -->
                <th width="10%">車牌</th>
                <th width="6%">洗車類型</th>
                <th width="6%">洗車费</th>
                <th width="6%">实付金额</th>
                <th width="6%">客戶(手機號)</th>
                <th width="11%">下單時間</th>
                <th width="6%">訂單状态</th>
				<th width="6%">洗車狀態</th>
            </tr>

            <foreach name='orderList' item='vo' key="k">
                <tr>
                	<td class="bgce1" colspan="8">
                        <span style="float: left;padding-left: 5%;">
                            商戶訂單號：<span style="color:#ff8800">{$vo.ordersn}</span>
                        </span>
                        <span style="float: right;padding-right: 5%;">
                            <a href="{:U(MODULE_NAME.'/Orders/order_details',array('id'=>$vo['order_id']))}">查看詳情</a>
                            <if condition="$vo['status'] eq -1">
                            ——&nbsp;&nbsp;
                            <a href="{:U(MODULE_NAME.'/Orders/refund_audit_view',array('id'=>$vo['order_id']))}">退款審核</a>
                            </if>
                        </span>
                    </td>
                </tr>
                <tr>
                	<td class="txtc">{$vo.license_plate}</td>
                	<td class="txtc">
                		<p>
                		<if condition="$vo.card_type eq 1">
                		次卡
                		<elseif condition="$vo.card_type eq 2"/>
                		周卡
                		<elseif condition="$vo.card_type eq 3"/>
                		月卡
                		<elseif condition="$vo.card_type eq 4"/>
                		年卡
                		</if>
                		</p>
                	</td>
                	<td class="txtc">
                		<p>￥{$vo.price}</p>
                	</td>
                	<td class="txtc">
                		<p>￥{$vo.real_price}</p>
                	</td>
                	<td class="txtc" rowspan="{$vo.orders_goods_count}"><p>{$vo.order_phone}</p></td>
                	<td class="txtc" rowspan="{$vo.orders_goods_count}">{$vo.o_create_time|date="Y-m-d H:i:s",###}</td>
                	<td class="txtc" rowspan="{$vo.orders_goods_count}">
                		<switch name="vo['status']">
					            <case value="1">已付款</case>
                                <case value="0">未付款</case>
                                <case value="-1">退款審核中</case>
                                <case value="-2">退款審核成功</case>
                                <case value="-3">退款中</case>
                                <case value="-4">退款成功</case>
								<default>非法訂單
						</switch>
					</td>
					<td class="txtc">
					<if condition="$vo['status'] eq 1 and $vo['wash_status'] eq 0">
                		<input type="button" class="select_{$k}" value="派遣員工">

                		<div id="add_name_{$k}" style="display:none;">
							<form method="post" id="upForm111">
					            <table class="edit_table">
    					            <tr>
    					                <td class="tablehead">员工</td>
    					                <td>
    					                <foreach name="vo['server_address_staff']" item='v' key="kk">
    					                	<input type="checkbox" staff_id="{$v.id}">{$v.name}
    				                		<if condition="$kk%3 eq 0 and $kk neq 0">
    				                			<br/>
    				                		</if>
    					                </foreach>
    					                <input type="hidden" name="staff_id">
    					                <input type="hidden" name="ordersn" value="">
    					                <input type="hidden" name="server_address_id" value="{$vo.server_address_id}">
    					                </td>
    					            </tr>
    					            <tr>
    					                <td class="tablehead"></td>
    					                <td><input type="button" ordersn="{$vo.ordersn}" name="confirm_select" value="确认" style="padding:6px 20px;"/></td>
    					            </tr>
					            </table>
					        </form>
					    </div>
                    <elseif condition="$vo['status'] eq 1 and $vo['wash_status'] eq 1"/>
						已安排
                    <elseif condition="$vo['status'] eq 1 and $vo['wash_status'] eq 2"/>
                        洗車完成
                    <elseif condition="$vo['status'] lt 1 and $vo['wash_status'] eq 0"/>
                        未安排
                	</if>

                	</td>
                </tr>
                <tr style="height:10px;" >
                	<td class="bgcf5"colspan="8"></td>
                </tr>
            </foreach>
        </table>
    </form>
    <div class="page">{$page}</div>
</div>

<include file="Common:footer" />
<script type="text/javascript">

 // $('.select_orders_status').click(function(){
	//  var choose = $(this).text();
	//  var url = "{:U(MODULE_NAME.'/'.CONTROLLER_NAME.'/'.ACTION_NAME)}";
	//  var type = "post";
 //  	 var dataType = "JSON";
 //  	 var async = "true";
 //  	    $.ajax({
 // 			url: url,
 // 			type: type,
 // 			dataType: dataType,
 // 			data:{choose : choose},
 // 			async: async,
 // 	    	success: function (data) {
 // 	    		if (data.status == 1){
 // 	    			callBackTips(data.status, data.info,data.url);
 // 	    		}else{
 // 	    			callBackTips(data.status, data.info,data.url);
 // 	    		}
 // 	    	}
 //        });
 // });

<foreach name='orderList' item='vo' key="k">
	$('.select_{$k}').click(function(){
		art.dialog({
			content: document.getElementById('add_name_{$k}'),
	});
	});
</foreach>

$('input[name=confirm_select]').click(function(){
 		var staff_id = '';
		$('input[type=checkbox]').each(function(){
			if($(this).prop('checked')){
				staff_id = $(this).attr('staff_id') + ',' + staff_id;
			}
		});
		$('input[name=staff_id]').val(staff_id);
		$('input[name=ordersn]').val($(this).attr('ordersn'));
		/* alert($('input[name=ordersn]').val());return; */
		var formData = new FormData($( "#upForm111" )[0]);
	$.ajax({
        url: "{:U(MODULE_NAME.'/'.CONTROLLER_NAME.'/select_washer')}" ,
        type: 'POST',
        data : formData,
        async: false,
        cache: false,
        contentType: false,
        processData: false,
        success: function (returndata) {
       		if(returndata.status){
       			callBackTips(returndata.status,returndata.info,returndata.url);
    		}else{
    			callBackTips(0,returndata.info);
    		}
        },
   });
});
</script>
